<?xml version="1.0" encoding="utf-8"?>
<mx:ApolloApplication xmlns:mx="http://www.adobe.com/2006/mxml"
title="Hello Apollo World"
creationComplete="initApp()"
layout="vertical"
backgroundColor="#FFFFFF" width="100%" height="100%">
<mx:Script>
<![CDATA[
import flash.utils.Timer;
import flash.events.TimerEvent;
import com.pearsoned.apollo.actionscripts.BridgeSound;
import com.pearsoned.apollo.actionscripts.ConnectionStatus;
[Embed(source="assets/images/helloapollologo.png")]
[Bindable] private var imgHelloApollo:Class;
[Embed(source="assets/images/helloapolloworld1.png")]
[Bindable] private var imgHelloApolloWorld:Class;
[Embed(source="assets/images/helloapolloworld2.png")]
[Bindable] private var imgHelloApolloWorld2:Class;
[Embed(source="assets/images/helloapolloworld3.png")]
[Bindable] private var imgHelloApolloWorld3:Class;
[Embed(source="assets/images/helloapolloworld4.png")]
[Bindable] private var imgHelloApolloWorld4:Class;
[Bindable] private var myTimer:Timer = new Timer(200, 0);
[Bindable] private var counter:int = 0;
private var mySound:BridgeSound = new BridgeSound();
private var myTimer2:Timer = new Timer(12000, 1);
private var connection:ConnectionStatus = new ConnectionStatus();
[Bindable] public var blnConnected:Boolean = true;
[Bindable] public var blnPlayEnabled:Boolean = false;
private function initApp():void {
Shell.shell.addEventListener(Event.NETWORK_CHANGE, connection.onConnectionChange);
connection.checkConnection();
myTimer.addEventListener("timer", onTimer);
startHelloTimer();
mySound.url = "http://labs.insideflex.com/apollotraining/apolloworld/assets/sounds/STbridge.MP3";
mySound.getSound();
myTimer2.addEventListener("timer", onTimer2);
myTimer2.start();
}
private function soundCompleteHandler(event:Event):void {
blnPlayEnabled = true;
}
private function playSoundEffects():void {
mySound.url = "http://labs.insideflex.com/apollotraining/apolloworld/assets/sounds/STbridge.MP3";
mySound.getSound();
mySound.song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
myTimer2.addEventListener("timer", onTimer2);
myTimer2.start();
}
private function startHelloTimer():void {
myTimer.start();
}
private function onTimer(event:TimerEvent):void {
switch (counter) {
case 1:
imgApolloLogo.source = imgHelloApolloWorld;
break;
case 2:
imgApolloLogo.source = imgHelloApolloWorld2;
break;
case 3:
imgApolloLogo.source = imgHelloApolloWorld3;
break;
case 4:
imgApolloLogo.source = imgHelloApolloWorld4;
counter = 0;
break;
default:
imgApolloLogo.source = imgHelloApollo;
break;
}
counter++;
}
private function onTimer2(event:TimerEvent):void {
mySound.url = "http://labs.insideflex.com/apollotraining/apolloworld/assets/sounds/fascinating.MP3";
mySound.getSound();
}
private function goThere(sURL:String):void {
var u:URLRequest = new URLRequest(sURL);
navigateToURL(u,"_blank");
}
]]>
</mx:Script>
<mx:Style>
<!-- style for the toolTip displayed when mousing over Flex components -->
ToolTip { font-family: ; font-size: 14; font-weight: ;
background-color: ; color: ; }
</mx:Style>
<mx:Spacer height="80"/>
<mx:Image id="imgApolloLogo" source="http://labs.insideflex.com/apollotraining/apolloworld/assets/images/apollologo.png"/>
<mx:Spacer height="40"/>
<mx:HBox>
<mx:Button id="btnPlayAgain" label="Play Again" click="playSoundEffects();blnPlayEnabled=false" fontFamily="Verdanna"
fontSize="14" fontWeight="bold" toolTip="{(blnPlayEnabled)?'Click to play the sound effects again...':'Button is currently inactive...'}" enabled="{blnPlayEnabled}"/>
<mx:Button id="btnViewSource" label="Source" click="goThere('http://labs.insideflex.com/apollotraining/apolloworld/bin/srcview/index.html')" fontFamily="Verdanna"
fontSize="14" fontWeight="bold" toolTip="{(blnConnected)?'Click to view the source code...':'Offline mode - button is currently inactive...'}"/>
<mx:Button id="btnExit" label="Exit" click="window.close()" fontFamily="Verdanna"
fontSize="14" fontWeight="bold" toolTip="Click to exit the application..."/>
</mx:HBox>
<mx:Spacer height="40"/>
<mx:Image id="imgStatus" width="24" height="24"/>
</mx:ApolloApplication>